package top.mayyd.producteurekaservice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.mayyd.producteurekaservice.domain.Product;
import top.mayyd.producteurekaservice.service.ProductService;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public Product show(@PathVariable("id") Long id) {
        return productService.getById(id);
    }


    @RequestMapping(name = "")
    public List<Product> index() {
        return productService.getAll();
    }


}
